package com.headline.service;

import com.headline.common.Common;
import com.headline.common.PageObject;
import com.headline.dao.SpiderNewsInfoDao;
import com.headline.model.RecommondArticleResult;
import com.headline.model.SpiderNewsInfoEntity;

import java.util.List;

/**
 * Created with Administrator
 * DATE:2016/11/7
 * Time:16:08
 */
public class SpiderNewsInfoService {


    SpiderNewsInfoDao spiderNewsInfoDao = new SpiderNewsInfoDao();

    public int insertUser(SpiderNewsInfoEntity spiderNewsInfoEntity) {
        return spiderNewsInfoDao.insertSpiderNewsInfo(spiderNewsInfoEntity);
    }

    public List<SpiderNewsInfoEntity> queryList(String strWhere) {
        return spiderNewsInfoDao.queryList(strWhere);
    }

    public SpiderNewsInfoEntity querySpiderNewsInfoById(int id) {
        return spiderNewsInfoDao.querySpiderNewsInfoById(id);
    }

    public int updateSpiderNewsInfo(SpiderNewsInfoEntity spiderNewsInfoEntity) {

        return spiderNewsInfoDao.updateSpiderNewsInfo(spiderNewsInfoEntity);
    }

    public int deleteSpiderNewsInfoById(int id) {
        return spiderNewsInfoDao.deleteSpiderNewsInfoById(id);
    }

    public PageObject queryPage(int pageIndex, int pageSize) {
        return spiderNewsInfoDao.queryPage(pageIndex, pageSize);
    }

    /**
     * @param max_id   下拉id
     * @param since_id 上拉id
     * @return
     */
    public List<RecommondArticleResult> queryApp(int max_id, int since_id) {
        List<RecommondArticleResult> list = spiderNewsInfoDao.queryApp(max_id, since_id);
        if (list != null && list.size() > 0) {
            for (RecommondArticleResult rar : list) {
                rar.setOpenscheme(Common.getOpenScheme(rar.getId(),rar.getTitle()));
            }
        }
        return list;
    }

}
